/*
 * \brief  Client-side I/O-memory session interface
 * \author Christian Helmuth
 * \date   2006-08-01
 */

/*
 * Copyright (C) 2006-2009 Christian Helmuth
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__IO_MEM_SESSION__CLIENT_H_
#define _INCLUDE__IO_MEM_SESSION__CLIENT_H_

#include <io_mem_session/capability.h>
#include <base/ipc.h>
#include <base/lock.h>

namespace Genode {

	class Io_mem_session_client : public Io_mem_session
	{
		private:

			Msgbuf<32> _snd_msg, _rcv_msg;
			Ipc_client  _ipc_client;
			Lock        _lock;

		public:

			/**
			 * Constructor
			 */
			Io_mem_session_client(Io_mem_session_capability session)
			: _ipc_client(session, &_snd_msg, &_rcv_msg) { }


			/*****************************
			 ** Io_mem session interface **
			 *****************************/

			Io_mem_dataspace_capability dataspace()
			{
				Io_mem_dataspace_capability ds;  /* default is an invalid capability */
				Lock::Guard lock_guard(_lock);

				_ipc_client << DATASPACE << IPC_CALL >> ds;

				return ds;
			}
	};
}

#endif /* _INCLUDE__IO_MEM_SESSION__CLIENT_H_ */
